#ifndef _SIMON_H_
#define _SIMON_H_

#include "Sprite.h"
#include "Object.h"
#include "Rod.h"
#include "Axe.h"
#include "Dagger.h"
#include "HolyWater.h"
#include "Boomerang.h"
#include "CastleVaniaGame.h"

#include <list>
using namespace std;

#define SIMON_VX	0.15 //0.15
#define SIMON_VY	0.63//1.1	//1.8
#define GRAVITY		0.002	//0.005 //0.01
#define ACCEL_X		0.001
#define BOTTOM		0
#define SIMON_VX_MAX 0.25

class CastleVaniaGame;

/**--------------------------------------------------------
*Program/Project : CastleVania
*Written by : 
*Email :
*Created date : 7/10/2012
*Modified by :
*Modified date :
*Version : 1.0
*Description : Lop khoi tao Simon
--------------------------------------------------------**/
class Simon: public Object
{
private:
	LPDIRECT3DDEVICE9 d3ddv;
	LPDIRECT3DSURFACE9 backBuffer;
	LPD3DXSPRITE spriteHandler;


	Sprite* p_sprite_go;		//Sprite simon

	//Sprite* p_spriteBig;		//Sprite mario lon

	//Sprite* p_spriteBullet;		//Sprite mario co bullet
	

	Sprite* p_sprite_stair;		//Sprite player khi going stair
	Sprite* p_sprite_player_rod;
	Sprite* p_sprite_die;		//Sprite simon die
	

	//0: Left | 1: Right
	bool is_turn_left;			//kiem tra huong
	bool is_jump;				//kiem tra nhay

	bool isShoot;				//kiem tra mario duoc ban bullet hay chua
	bool isHasStar;				//kiem tra mario co an sao hay chua?
	bool isMoveDown;			//Kiem tra mario co the chuoi cong
	bool isGravity;				//Xet trong luc khi va cham
	bool isDieFall;				//Chet do roi xuong ho

	//CastleVania Rod
	bool isFight;				//Danh roi
	int countFrameRod;			//Diem sl frame
	

	bool is_going_stair;		//kiem tra co di len/xuong cau thang k?
	bool is_until_go_out_stair;	//kiem tra va cham voi dinh cau thang


	int isUp;					//kiem tra tinh trang len/xuong cau thang?

	bool is_up_left;			//kiem tra len cau thang ben trai/phai?
	int is_direction_stair;		//huong khi len/xuong cau thang.
	//1:len trai, 2: len phai
	//3:xuong trai, 4: xuong phai

	float x_temp;
	float y_temp;
	
	bool is_active_axe;			//active vu khi axe
	int weapon_version;
	int rod_version;			//thu tu rod
	bool is_left_die;
	int const_width;
	

	//////////////////////////////////////////////////////////////////////////
	 
	float timeBullet;				//khoang thoi gian sau 1 lan ban bullet
	float timeTransferState;		//khoang thoi gian chuyen frame

	int countFrame;					//so frame chuyen
	float timeProtect;				//thoi gian bao ve sau khi chet

	
	/*
	 *	Vu khi cua simon
	 */
	Rod* p_rod;
	Axe* p_axe;
	Dagger* p_dagger;
	HolyWater* p_holy_water;
	Boomerang* p_boomerang;
	
public:
	/*
	 *	Set/Get Properties
	 */
	D3DXVECTOR2 getPosition();
	int getWeaponVersion() {return weapon_version;}
	void setWeaponVersion(int axe_version) {this->weapon_version = axe_version;}
	int getRodVersion() {return rod_version;}
	void setRodVersion(int rod_version) {this->rod_version = rod_version;}
	bool getWay() {return is_turn_left;}

	CastleVaniaGame *game_main;
	 

	/*
	 *	Constructor/Destructor
	 */
	Simon(LPDIRECT3DDEVICE9 d3ddv,  LPDIRECT3DSURFACE9 backBuffer, LPD3DXSPRITE spriteHandler, float x, float y, CastleVaniaGame* Game_Mario, int Obj_state, int Direction);
	~Simon(void);

	
	/*
	 *	Method
	 */	
	void update(list<Object*>* obj_list, DxInput* input, float TPF);
	
	void move(list<Object*>* obj_list, float time, DxInput *p_input);
	void moveDieState(list<Object*>* obj_list, float time, DxInput *p_input);
	
	void render(int cameraX, int cameraY);	 

	//ham dieu khien input
	void processInput(DxInput *p_input);

	void turnUp();
	void turnDown();
	void turnLeft();
	void turnRight();
	void jump();
	void reset();

	void fight();
	void activeAxe();

	void goingStairOut();

	void changeState(int state);
};

#endif
